<%@ page import="com.example.model.SystemAdmin" %>
<%@ page import="com.example.model.ManagementUser" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="header.jsp" %>
<%
    // 检查用户是否已登录
    if (session.getAttribute("admin") == null &&
            session.getAttribute("managementUser") == null) {
        response.sendRedirect("login");
        return;
    }
%>
<html>
<head>
    <title>首页</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
</head>
<body>
<div class="container">
    <div class="welcome-container">
        <h1>欢迎回来</h1>
        <%
            if (session.getAttribute("admin") != null) {
                SystemAdmin admin = (SystemAdmin) session.getAttribute("admin");
                out.println("<p>用户名: " + admin.getUsername() + "</p>");
                out.println("<p>角色: 系统管理员</p>");
            } else if (session.getAttribute("managementUser") != null) {
                ManagementUser user = (ManagementUser) session.getAttribute("managementUser");
                out.println("<p>用户名: " + user.getUsername() + "</p>");
                out.println("<p>角色: 用户</p>");
            }
        %>
        <a href="login?logout=true" class="logout-btn">退出登录</a>
    </div>
</div>
</body>
</html>